﻿using System;
using UnityEngine;

// Token: 0x0200000C RID: 12
public class DamageReceiver : MonoBehaviour
{
	// Token: 0x06000033 RID: 51 RVA: 0x000073E4 File Offset: 0x000055E4
	public void Damage(float dmg)
	{
		this.body.Damage(dmg * this.damageMult, dmg * this.hitStunMult);
	}

	// Token: 0x06000034 RID: 52 RVA: 0x00007404 File Offset: 0x00005604
	public void DoWound(int type, Vector2 pos)
	{
		if (type == 0 && !this.canGetBluntWounds)
		{
			return;
		}
		GameObject gameObject = (GameObject)Object.Instantiate(Resources.Load("Wound"));
		gameObject.transform.position = Vector2.Lerp(base.transform.position, pos, Random.Range(0f, 0.9f));
		gameObject.transform.eulerAngles = new Vector3(0f, 0f, Random.Range(0f, 360f));
		gameObject.transform.SetParent(base.transform);
		gameObject.GetComponent<SpriteRenderer>().sortingOrder = base.GetComponent<SpriteRenderer>().sortingOrder + 1;
		gameObject.GetComponent<SpriteRenderer>().color = this.body.bloodColor;
		switch (type)
		{
		case 0:
			gameObject.GetComponent<SpriteRenderer>().sprite = this.body.bluntWounds[Random.Range(0, this.body.bluntWounds.Length)];
			break;
		case 1:
			gameObject.GetComponent<SpriteRenderer>().sprite = this.body.cutWounds[Random.Range(0, this.body.cutWounds.Length)];
			break;
		case 2:
			gameObject.GetComponent<SpriteRenderer>().sprite = this.body.gunshotWounds[Random.Range(0, this.body.gunshotWounds.Length)];
			break;
		}
		this.body.lastDamagedLimb = base.transform;
		this.body.lastDamagedLimbPos = base.transform.InverseTransformPoint(pos);
	}

	// Token: 0x06000035 RID: 53 RVA: 0x0000759C File Offset: 0x0000579C
	public void TryGore(Vector2 pos, int type, float dmg)
	{
		if (!this.body.hasGore && this.body.health < 0f)
		{
			if ((type == 0 && dmg > 35f) || (type == 1 && dmg > 20f))
			{
				GameObject gameObject = null;
				if (type != 0)
				{
					if (type == 1)
					{
						gameObject = (GameObject)Object.Instantiate(Resources.Load("GoreHoles/Sharp" + Random.Range(1, 3).ToString()));
					}
				}
				else
				{
					gameObject = (GameObject)Object.Instantiate(Resources.Load("GoreHoles/Blunt" + Random.Range(1, 3).ToString()));
				}
				gameObject.transform.position = Vector2.LerpUnclamped(pos, base.transform.position, Random.Range(-0.35f, 0f));
				gameObject.transform.eulerAngles = new Vector3(0f, 0f, Random.Range(0f, 360f));
				gameObject.GetComponent<SpriteRenderer>().color = this.body.bloodColor;
				gameObject.transform.SetParent(base.transform);
				gameObject.transform.localScale = new Vector3(Random.Range(0.8f, 1.2f), Random.Range(0.8f, 1.2f), 1f);
			}
			this.body.hasGore = true;
		}
	}

	// Token: 0x06000036 RID: 54 RVA: 0x00007710 File Offset: 0x00005910
	public void DecapWound()
	{
		Vector2 vector = base.transform.TransformPoint(this.body.head.GetComponent<HingeJoint2D>().connectedAnchor) + base.transform.up * 0.18f;
		GameObject gameObject = (GameObject)Object.Instantiate(Resources.Load("Wound"));
		gameObject.transform.position = vector;
		gameObject.transform.SetParent(base.transform);
		gameObject.transform.localEulerAngles = Vector3.zero;
		gameObject.GetComponent<SpriteRenderer>().sortingOrder = base.GetComponent<SpriteRenderer>().sortingOrder + 1;
		gameObject.GetComponent<SpriteRenderer>().color = this.body.bloodColor;
		gameObject.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("Blood/dismemberSprite");
		this.body.lastDamagedLimb = base.transform;
		this.body.lastDamagedLimbPos = base.transform.InverseTransformPoint(vector);
		GameObject gameObject2 = (GameObject)Object.Instantiate(Resources.Load("Wound"));
		gameObject2.transform.position = vector - base.transform.up * 0.18f;
		gameObject2.transform.SetParent(this.body.head.transform);
		gameObject2.transform.localEulerAngles = Vector3.zero;
		gameObject2.GetComponent<SpriteRenderer>().sortingOrder = this.body.head.GetComponent<SpriteRenderer>().sortingOrder + 1;
		gameObject2.GetComponent<SpriteRenderer>().color = this.body.bloodColor;
		gameObject2.GetComponent<SpriteRenderer>().sprite = Resources.Load<Sprite>("Blood/dismemberSplash");
	}

	// Token: 0x040000B3 RID: 179
	public float damageMult;

	// Token: 0x040000B4 RID: 180
	public float hitStunMult;

	// Token: 0x040000B5 RID: 181
	public BodyScript body;

	// Token: 0x040000B6 RID: 182
	public bool canGetBluntWounds;
}
